my $reload = 0;

my @opts;
push @opts, '-m', fetch_val('syslog_mark_interval') || 0;
push @opts, '-r' if fetch_val('syslog_server');
push @opts, '-s', join(":", comma_or_arrayref(fetchall_array('syslog_strip_domains'))) if fetch_val('syslog_strip_domains');

file_append('/etc/sysconfig/syslog', "SYSLOGD_OPTIONS=\"@opts\"\n", qr/^SYSLOGD_OPTIONS=/)
    and $reload++;

if (my $syslog_remote = fetchall_hash('syslog_remote'))
{
    while (my ($target, $what) = each %{ $syslog_remote })
    {
	unless ($what)
	{
	    file_comment('/etc/syslog.conf', qr/^\S+\s+\@\Q$target\E\b/)
		and $reload++;
	    next;
	}

	file_append('/etc/syslog.conf', "$what\t\t\t\t\t\@$target\n", qr/^\S+\s+\@\Q$target\E\b/)
	    and $reload++;
    }
}

my $sync = fetch_val('syslog_sync') ? '' : '-';

file_modify('/etc/syslog.conf', -eval=>sub { s|^(?!\s*#)(\S+\s+)-?(/.*)|$1$sync$2| })
    and $reload++;

command("service syslog restart")
    if $reload;

1;
